﻿using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02创建图形
{
    public  class PolyLineExam
    {
        [CommandMethod("PolyLineDemo")]
        public void PolyLineDemo()
        {
            #region
            //Polyline pl = new Polyline();
            //Point2d p1 = new Point2d(100,100);
            //Point2d p2 = new Point2d(200,100);
            //Point2d p3 = new Point2d(200,200);
            //pl.AddVertexAt(0, p1, 0, 0, 0);
            //pl.AddVertexAt(1, p2, 0, 0, 0);
            //pl.AddVertexAt(2, p3, 0, 0, 0);
            //pl.Closed = true;
            //pl.ConstantWidth = 50;
            //Database db = HostApplicationServices.WorkingDatabase;
            ////db.AddEnityToModelSpace(pl);

            //db.AddPolyLineToModelSpace(false, 0, new Point2d(10, 10), new Point2d(50, 10), new Point2d(100, 20));
            //db.AddPolyLineToModelSpace(true, 0, new Point2d(10, 50), new Point2d(50, 50), new Point2d(100, 70));
            #endregion
            #region
            //Polyline pLine = new Polyline();
            //Polyline pLine2 = new Polyline();
            //Polyline pLine3 = new Polyline();
            //Point2d p1 = new Point2d(100, 100);
            //Point2d p2 = new Point2d(100, 200);
            //pLine.AddVertexAt(0, p1, 1, 0, 0);
            //pLine.AddVertexAt(1, p2, 0, 0, 0);

            //pLine2.AddVertexAt(0, p1, 0.5, 0, 0);
            //pLine2.AddVertexAt(1, p2, 0, 0, 0);

            //pLine3.AddVertexAt(0, p1, 6, 0, 0);
            //pLine3.AddVertexAt(1, p2, 0, 0, 0);
            //Database db = HostApplicationServices.WorkingDatabase;
            ////db.AddEnityToModelSpace(pLine,pLine2,pLine3);

            //Polyline pline = new Polyline();
            //Point2d p1 = new Point2d(100, 100);
            //Point2d p2 = new Point2d(500, 100);
            //Point2d p3 = new Point2d(500, 200);
            //Point2d p4 = new Point2d(100, 200);
            //pline.AddVertexAt(0, p1, 0, 0, 0);
            //pline.AddVertexAt(1, p2,1, 0, 0);
            //pline.AddVertexAt(2, p3, 0, 0, 0);
            //pline.AddVertexAt(3, p4, 1, 0, 0);
            //pline.Closed = true;
            //db.AddEnityToModelSpace(pline);
            #endregion

            Database db = HostApplicationServices.WorkingDatabase;
            //db.AddRectToModelSpace(new Point2d(0,0),new Point2d(100,100));

            //db.AddRectToModelSpace(new Point2d(200,200),new Point2d(100,100));

            //db.AddRectToModelSpace(new Point2d(500,500),new Point2d(100,100));

            db.AddPolygonToModelSpace(new Point2d(100, 100), 50, 3,90);
            db.AddPolygonToModelSpace(new Point2d(200, 100), 50, 4,45);
            db.AddPolygonToModelSpace(new Point2d(300, 100), 50, 5,90);
            db.AddPolygonToModelSpace(new Point2d(400, 100), 50, 6,0);
            db.AddPolygonToModelSpace(new Point2d(500, 100), 50, 12,0);

        }
    }
}


